<?php
require_once('Database.class.php');
$db = Database::getInstance();
$db->getConnection(); 
session_start();

$login = isset($_POST["login"]) ? $_POST["login"] : "";
$password = isset($_POST["password"]) ? $_POST["password"] : "";

$query = "SELECT id_usuario, pass FROM usuario WHERE login = '$login'";
$result = mysql_query($query);
$nbrows = mysql_num_rows($result);
if($nbrows>0){
	$rec = mysql_fetch_array($result);
	if( $password == $rec['pass'] ){
		$_SESSION['login'] = "si";
		$_SESSION['id_usuari'] = $rec['id_usuario'];
		echo "{success: true}";
	}else{
		$_SESSION['login'] = "no";
		echo "{failure: true}";
	}
} else {
	$_SESSION['login'] = "no";
	echo "{failure: true}";
}
include("desconnexio.php");
?>